#include <iostream>
#include <vector>
using namespace std;

class Solution {
public:
    int removeDuplicates(vector<int>& nums)
    {
        vector<int>::iterator it = nums.begin();
        while (it != nums.end())
        {
            int k = *it;
            vector<int>::iterator itt = it + 1;
            while (itt != nums.end())
            {
                if (*itt == k)
                {
                    vector<int>::iterator end = itt + 1;
                   
                    while (end != nums.end())
                    {
                        *(end - 1) = *end;
                        end++;
                    }
                    nums.pop_back();

                }
                else
                {
                    itt++;
                }
            }
            it++;
        }
        return nums.size();
    }
};

int main()
{
    vector<int> num;
    num.push_back(1);
    num.push_back(1);
    num.push_back(2);
    Solution s;
    int ret = s.removeDuplicates(num);
    cout << ret << endl;
    for (auto e : num)
    {
        cout << e << " ";
    }
    cout << endl;
	return 0;
}